#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
#endregion

namespace pong
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class cObjetos : Microsoft.Xna.Framework.GameComponent
    {

        public  BoundingBox BB= new BoundingBox();
/*        public BoundingBox BBox
        {
            get
            {
                return BB;
            }
        }
  */
        protected Model Modelo3d;
        protected Vector3 anchoAltoLargo = Vector3.Zero;
        protected float ancho=0;
        protected float alto = 0;
        protected float radio = 0;
        protected Vector3 posicion = Vector3.Zero;


        protected void updateBoundingBox()
        {
            BB.Max.X = posicion.X + (0.5f);
            BB.Max.Y = posicion.Y + (alto / 2);
            BB.Max.Z = posicion.Z + (ancho / 2);//
            BB.Min.X = posicion.X - (0.5f);
            BB.Min.Y = posicion.Y - (alto / 2);
            BB.Min.Z = posicion.Z - (ancho / 2);//
        }

        protected float alpha=0;

        public float Alpha
        {
            set
            {
                alpha = value;
            }
            get
            {
                return alpha;
            }
        }


        public Vector3 Posicion
        {
            get
            {
                return posicion;
            }
        }


        /*************************************************/
        /*************************************************/
        /*************************************************/

        
        public cObjetos(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
        }


        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public void Initialize(float _alpha)
        {
            // TODO: Add your initialization code here
            alpha = _alpha;
            base.Initialize();
        }

        public void Initialize(float _alpha, float _ancho, float _alto)
        {
            // TODO: Add your initialization code here
            ancho = _ancho;
            alto = _alto;
            alpha = _alpha;
            base.Initialize();
        }

        public void Initialize(float _alpha, float _radio)
        {
            radio = _radio;
            alpha = _alpha;
            base.Initialize();
        }




        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            base.Update(gameTime);
        }

        
        
        
        public void load(ContentManager content,string strRutaArchivo)
        {
            
            Modelo3d = content.Load<Model>(strRutaArchivo);
            //BB = new BoundingBox();
            //BB = new BoundingBox(Modelo3d

        }
        


//        cCamara 
       
        public void Draw ()
        {

            Matrix[] Transformaciones = new Matrix[Modelo3d.Bones.Count];
            Modelo3d.CopyAbsoluteBoneTransformsTo(Transformaciones);
            foreach (ModelMesh mesh in Modelo3d.Meshes)
            {
                foreach (BasicEffect efecto in mesh.Effects)
                {
                    efecto.GraphicsDevice.RenderState.DepthBufferEnable = true;
                    efecto.GraphicsDevice.RenderState.DepthBufferFunction = CompareFunction.LessEqual;
                    efecto.GraphicsDevice.RenderState.DepthBufferWriteEnable = true;

                    //Activar la luz  por defecto
                    efecto.EnableDefaultLighting();
                    efecto.SpecularColor = new Vector3(0.1f, 0.1f, 0.3f);
                    efecto.SpecularPower = 100f;
                    efecto.Alpha = alpha;
                   // efecto.TextureEnabled = true;
                   
//                    efecto.EnableDefaultLighting();
                    efecto.World = Matrix.CreateTranslation(0, 0, 0);
                    efecto.World =/* Transformaciones[mesh.ParentBone.Index] * Matrix.CreateRotationY(Rotacion)**/ Matrix.CreateTranslation(posicion); 
                    efecto.View = cCamara.view;
                    efecto.Projection = cCamara.projection;
                }
                mesh.Draw();
            }
        }
    }

 

}


